import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { GTextFormat } from "../../../common/GTextFormat";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { ImagesConst } from "../../resource/ImagesConst";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { Cache } from "../../cache/Cache";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
type int = number;
//class KingWarNoteRenderer
    
    export  class KingWarNoteRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this._txArr = Language.getString(70410).split(",");
            this._glowYellow = new Object /* flash.filters.GlowFilter */(16776960, 1, 3, 3, 5);
            this.initView();
            return;
        }

        /* internal  */initView(): void
        {
            this._sbmDateBg = ObjCreate.createBitmap("", 0, 0, this);
            var loc1=new GTextFormat();
            loc1.align = flash.text.TextFormatAlign.CENTER;
            loc1.color = GlobalStyle.color1Uint;
            this._dayTx = ObjCreate.createTextField("", 26, 8, 52, 20, this, loc1);
            this._dayTx.filters = [FilterConst.glowFilter];
            this._bg = ObjCreate.createBg(2, 33, 102, 79, this, ImagesConst.RechargeBottom);
            this._dateTx = ObjCreate.createTextField("", 30, 54, 64, 20, this, GlobalStyle.textFormat2);
            this._decTx = ObjCreate.createTextField("", 3, 69, 100, 20, this, loc1);
            LoaderHelp.addResCallBack(ResFileConst.kingWar, this.onLoadBmResource);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._sbmDateBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.kingWar_NoteDayBg);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            if (arg1) 
            {
                this._year = arg1.year;
                this._month = arg1.month;
                this._date = arg1.day;
                this._type = arg1.type;
                this._newDate = new Date(this._year, this._month, this._date);
                this._dayTx.text = this._txArr[this._newDate.getDay()];
                this._dateTx.text = Language.getStringByParam(70409, this._newDate.getMonth() + 1, this._newDate.getDate());
                this._type = this.getDateType();
                this.showTypeTx();
            }
            return;
        }

        /* internal  */getDateType(): int
        {
            var loc2=null;
            var loc3=null;
            var loc1=Cache.instance.kingwar.getDateTipsArr();
            var loc4=0;
            while (loc4 < loc1.length) 
            {
                loc3 = loc1[loc4] as Date;
                if (loc3) 
                {
                    if (this._newDate.getFullYear() == loc3.getFullYear() && this._newDate.getMonth() == loc3.getMonth() && this._newDate.getDate() == loc3.getDate()) 
                    {
                        return loc4 + 1;
                    }
                    if (this._newDate.getTime() <= loc3.getTime()) 
                    {
                        return loc4;
                    }
                }
                ++loc4;
            }
            return 0;
        }

        /* internal  */showTypeTx(): void
        {
            var loc1=this._type;
            switch (loc1) 
            {
                case 0:
                {
                    this._decTx.text = Language.getString(70414);
                    break;
                }
                case 1:
                {
                    this._decTx.text = Language.getString(70415);
                    break;
                }
                case 2:
                {
                    this._decTx.text = Language.getString(70416);
                    break;
                }
                case 3:
                {
                    this._decTx.text = Language.getString(70417);
                    break;
                }
                case 4:
                {
                    this._decTx.text = Language.getString(70417);
                    break;
                }
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (arg1) 
            {
                this.setClickState(true);
            }
            else 
            {
                this.setClickState(false);
            }
            return;
        }

        public setClickState(arg1: Boolean): void
        {
            if (this._gradientGlow == null) 
            {
                this._gradientGlow = new Object /* flash.filters.GradientGlowFilter */();
                this._gradientGlow.distance = 0;
                this._gradientGlow.angle = 45;
                this._gradientGlow.colors = [16777062, 16776960];
                this._gradientGlow.alphas = [0, 1];
                this._gradientGlow.ratios = [0, 255];
                this._gradientGlow.blurX = 5;
                this._gradientGlow.blurY = 5;
                this._gradientGlow.strength = 2;
                this._gradientGlow.quality = flash.filters.BitmapFilterQuality.HIGH;
                this._gradientGlow.type = flash.filters.BitmapFilterType.OUTER;
            }
            if (arg1 && this._gradientGlow) 
            {
                this.filters = [this._gradientGlow];
            }
            else 
            {
                this.filters = [];
            }
            return;
        }

        /* internal */ /* var */_year: int;

        /* internal */ /* var */_month: int;

        /* internal */ /* var */_date: int;

        /* internal */ /* var */_type: int;

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_dayTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_decTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_dateTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_txArr: Array<any>;

        /* internal */ /* var */_newDate: Date;

        /* internal */ /* var */_sbmDateBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_glowYellow: Object /* flash.filters.GlowFilter */;

        /* internal */ /* var */_gradientGlow: Object /* flash.filters.GradientGlowFilter */;
    }
